home *** CD-ROM | disk | FTP | other *** search
- Path: ts2-022.jaxnet.com!user
- From: garyg@jax.jaxnet.com (Gary M. Greenberg)
- Newsgroups: comp.lang.c
- Subject: Re: What's your compiler's answer?
- Date: Sat, 10 Feb 1996 17:34:48 -0500
- Organization: Southeast Network Services, Inc.
- Message-ID: <garyg-1002961734480001@ts2-022.jaxnet.com>
- References: <1996Feb7.140945.28351@cs.rit.edu>
- NNTP-Posting-Host: ts2-022.jaxnet.com
-
- In article <1996Feb7.140945.28351@cs.rit.edu>, kar@cs.rit.edu (Kenneth A
- Reek) wrote:
-
- > In preparing some materials for a course, I wrote the following
- > program to illustrate that the order of expression evaluation is not
- > determined completely by the precedence of the operators involved. I
- > ran it on every compiler I could find and, not surprisingly, got lots of
- > different answers.
- [big chop]
- > Here's the program (hold on to your hats):
- >
- > int main(){
- > int i = 10;
- >
- > i = i-- - --i * ( i = -3 ) * i++ + ++i;
- > printf( "i = %d\n", i );
- > return 0;
- > }
- >
- > Results found to date:
- [worthless stuff clipped]
-
- Why not just teach your students that programs which invoke
- undefined behavior return results which they deserve. ;-)
-
- > Kenneth A. Reek kar@cs.rit.edu
-
- C'ya,
-
- gary /* the Sorcerer's Apprentice */
-
- "Why do we have to hide from the police, Daddy?"
- "Because we use vi, honey. They use emacs."
- "Unless we're on a Mac, then we use BBEdit 'cause `It Doesn't Suck!'"
-